using System;

namespace UserManagement
{
    /// <summary>
    /// User类：只定义字段、属性和构造函数
    /// </summary>
    public class User
    {
        private long _id;
        private string _username;
        private string _password;
        private string _email;
        
        // 无参构造函数
        public User()
        {
        }
        
        // 带参构造函数
        public User(long id, string username, string password, string email)
        {
            _id = id;
            _username = username;
            _password = password;
            _email = email;
        }
        
        // 属性
        public long Id
        {
            get => _id;
            set => _id = value;
        }
        
        public string Username
        {
            get => _username;
            set => _username = value;
        }
        
        public string Password
        {
            get => _password;
            set => _password = value;
        }
        
        public string Email
        {
            get => _email;
            set => _email = value;
        }
        
        // Equals和GetHashCode方法
        public override bool Equals(object obj)
        {
            return obj is User user &&
                   _id == user._id &&
                   _username == user._username &&
                   _password == user._password &&
                   _email == user._email;
        }
        
        public override int GetHashCode()
        {
            return HashCode.Combine(_id, _username, _password, _email);
        }
        
        // ToString方法
        public override string ToString()
        {
            return $"User{{id={_id}, username='{_username}', password='{_password}', email='{_email}'}}";
        }
    }
}